//index.js
//获取应用实例
var app = getApp()
Page({
	data: {
		root:'',
		siteroot:app.setting.siteroot,
		att_url:app.setting.att_url,
		action:app.access.action,
		account:app.setting.account,
		show_coupon:true,
		pagetitle:'订单详情' + '-' + app.setting.title,
		
	},
	onReady: function (){
	},
	onPullDownRefresh: function (){
		var the=this;
		var opt={};
		the.onLoad(opt);
		setTimeout(function(){
			wx.stopPullDownRefresh()
		},1000);
	},
	onLoad: function (){
		var page=this;
		wx.setNavigationBarTitle({'title':page.data.pagetitle});
		app.util.get(app.access,function(pagedata){
			console.log('orderdetail');console.log(pagedata);			
			page.setData({
				pagedata:pagedata
			});
		});
	},
	del: function (e) {
		var pagedata=this.data.pagedata;
		var data = e.currentTarget.dataset;
		pagedata.list.splice(data.index,1);
		app.util.post('/store.manage.order/del/id='+data.id);
		this.setData({
				pagedata:pagedata,
		});
		
	},
	cancel:function(){
		app.util.post('/store.manage.order_detail/cancel/id='+this.data.pagedata.order.id);
	},
	confirm: function (e) {
		var pagedata=this.data.pagedata
		var data = e.currentTarget.dataset;
		pagedata.list[data.index].status=1;
		app.util.post('/store.manage.order_detail/confirm/id='+data.id);
		this.setData({
				pagedata:pagedata,
		});
	},
	show_verify: function (e) {
		var pagedata=this.data.pagedata
		var data = e.currentTarget.dataset;
		console.log(data);
		this.setData({
				show_verify_ewm:data.item.appcode,
				show_verify_code:data.item.verifycode?data.item.verifycode:data.item.verify_code,
				isshow_verify:true
		});
	},
	down_verify: function () {
		this.setData({
				isshow_verify:false
		});
	},
	closed_coupon:function(){
		this.setData({
			show_coupon:false
		});
	},
  	click:function(evt){
		//用户点击事件 data.func 为方法名，data.params 为调用参数！
		var data=evt.currentTarget.dataset;
		app.util[data.func](data.params);
	},
	setpay:function(e){
		var data=e.currentTarget.dataset;
		app.util.post('/store.manage.order_detail/setpay/id='+data.id,'',function(payid){
			app.util.pay(payid,function(res){		
				if(res.type=='success'){
					app.util.msg(res.message,'','jy_weishop/store.manage.order/');
				}else{
					app.util.msg(res.message);
				}
			});
		});
	}
});